var rotate=document.getElementsByClassName("rotate")[0];
function mouseMove(ev) {
	var x1;
	var y1;
	var x2;
	var y2;
	var currentX = -20;
	var currentY = 0;
	document.onmousedown = function (e) {
		var e = event || window.event;
		// e.preventDefault();
		x1 = e.clientX;
		y1 = e.clientY;
		this.onmousemove = function (e) {
			x2 = e.clientX;
			y2 = e.clientY;
			currentX += y2 - y1;
			currentY -= x2 - x1;
			ev.style.transform = "rotateY(" + (currentY) + "deg) rotateX(" + (currentX) + "deg)";
			x1 = x2;
			y1 = y2;
			this.onmouseup = function (e) {
				this.onmousemove = null;
			}
			return false;
		}
	}
}
mouseMove(rotate) ;